import os, sys, glob, shutil
from getpass import getpass

import paramiko    # ssh shell
from scp import SCPClient  # scp  file

import locale
import warnings

system_preferred_encoding = locale.getpreferredencoding()
warnings.filterwarnings('ignore')

ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(hostname="10.67.18.235", port=22, username="ryan", password=getpass())


# send command
stdin, stdout, stderr = ssh.exec_command("pwd")
# Consumable object: stdout can just read once
print(stdout.readlines())
print(stdout.read().decode(system_preferred_encoding))

stdin, stdout, stderr = ssh.exec_command("rmy -rf Pictures/Pictures")
stderr.readlines()

# transfer data fo linux
scpclient = SCPClient(ssh.get_transport(), socket_timeout=10.0)

#send or accept files
remote_dir = 'Pictures'
local_dir = os.getcwd()
scpclient.get(remote_dir, local_dir, recursive=True)
scpclient.put(files='Pictures', remote_path=remote_dir, recursive=True, preserve_times=True)

